import java.io.*;
import java.util.*;

public class BP_2BIT {
	String branchStatement;
	int correct = 0;
	int incorrect = 0;
	int countone = 0; int countzero = 0;
	private String[] items;
	private String BIA;
	private String BTA;
	private int outcome;
	private int prediction;
	
	class branch_trace {
		char BIA;
		char BTA;
		boolean br_outcome;
		static final int NOT_TAKEN = 0;
		static final int TAKEN = 1;
	}
	
	public BP_2BIT() {
		//constructor.
	}
	
	public static void main(String[] args) throws IOException {
		
		String inputFile = "input.txt";
		
		if (args.length == 1) {
			inputFile = (args[0]);
		}
		
		BP_2BIT schd = new BP_2BIT();
		
		twoBitPredictor p = new twoBitPredictor(0);
		
		Scanner s = null;
        try {
            s = new Scanner(new BufferedReader(
                    new FileReader(inputFile)));
        } catch (FileNotFoundException e) {
            //e.printStackTrace();
            System.out.println("read file...  " + 
            "input File not found exception");
            System.exit(0);
        }
        if (s == null) {
            System.exit(0);
        }
        
        while (s.hasNext()) {
            String str = s.nextLine();
            schd.items = str.split("\t");
            schd.BIA = schd.items[0].trim();
            schd.BTA = schd.items[1].trim();
            schd.outcome = (schd.items[2].charAt(0) == '0' ?
                    0:1);
            
            int index=0;
            index = p.add(schd.BIA, schd.BTA);
            schd.prediction = p.predict(schd.BIA, schd.BTA, index);
            if(schd.prediction == schd.outcome) {
                schd.correct++;
            } else {
            	schd.incorrect++;
            }
            p.update(index, schd.outcome);
            
            
            
        }
        
		float result = ((float)schd.correct/(float)(schd.correct+schd.incorrect))*100;
		System.out.format("%.3f\n", result);
		
		//System.out.println ("correct prediction = " + schd.correct);
		//System.out.println ("incorrect prediction = " + schd.incorrect);
	}
}
